<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>部门更新</title>
<s:include value="/app_common/common.jsp"></s:include>
<!-- 表单验证start -->
<script src="<s:property value='webctx'/>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<s:property value='webctx'/>/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->
<!-- 日期选择框start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->
<!-- 用户选择start -->
<script type="text/javascript" src="<s:property value='webctx'/>/app_common/userPopup/queryUser.js"></script>
<!-- 用户选择end -->
</head>
<body>
	<div class="box1" panelWidth="540">
		<form name="form2" id="form2" method="post" target="frmright">
			<s:if test="%{ea.e_id!=null&&ea.e_id!=0}">
				<s:hidden name="ea.e_id"></s:hidden>
								<%--所属人编码 --%>
				<s:hidden name="ea.e_submit_ucode" id="ea_submit_ucode"></s:hidden>
				<%--所属人名称 --%>
				<s:hidden name="ea.e_submit_uname" id="ea_submit_uname"></s:hidden>
				<%--所属分部--%>
				<s:hidden name="ea.e_submit_dpcode" id="ea_submit_dpcode"></s:hidden>
				<%--所属分部名称--%>
				<s:hidden name="ea.e_submit_dpname" id="ea_submit_dpname"></s:hidden>
			</s:if>
			<s:else>
				<%--所属人编码 --%>
				<s:hidden name="ea.e_submit_ucode" id="ea_submit_ucode" value="%{#session.u_code}"></s:hidden>
				<%--所属人名称 --%>
				<s:hidden name="ea.e_submit_uname" id="ea_submit_uname" value="%{#session.u_name}"></s:hidden>
				<%--所属分部--%>
				<s:hidden name="ea.e_submit_dpcode" id="ea_submit_dpcode" value="%{#session.userltdcode}"></s:hidden>
				<%--所属分部名称--%>
				<s:hidden name="ea.e_submit_dpname" id="ea_submit_dpname" value="%{#session.userltdname}"></s:hidden>
			</s:else>
			<table class="tableStyle" formMode="line">
				<tr>
					<th colspan="4">出差登记<s:property value="ea.e_id==0?'新增':'操作'"/></th>
				</tr>
				<tr>
					<td>所属部门：</td>
					<td>
						<select id="query_dp_id" class="validate[required]" name="ea.e_dpid" selectedvalue="<s:property value='ea.e_dpid'/>" data="<s:property value='json_val'/>"></select><span class="star">*</span>
					</td>
					<td>出差人姓名：</td>
					<td>
						<s:hidden id="user_code" name="ea.e_ucode"></s:hidden>
						<input type="text" id="user_name"  name="ea.e_uname" onclick="queryUserAll()" style="cursor: pointer;" class="query_user" value="<s:property value="ea.e_uname" />" class="validate[required,length[0,20]]"/><span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>出差时间：</td>
					<td><input type="text" id="e_date" name="ea.e_date" value="<s:property value="ea.e_date" />" class="date validate[required]"/><span class="star">*</span></td>
					<td>拜访客户数量：</td>
					<td><input type="text" id="ea.e_visit_count" name="ea.e_visit_count" value="<s:property value="ea.e_visit_count" />" class="validate[required],custom[onlyNumber]"/><span class="star">*</span></td>
				</tr>
				<tr>
					<td>出差行程说明：</td>
					<td colspan="3">
					<textarea style="width: 365px" name="ea.e_explain" id="visit" class="validate[required]" >
						<s:property value="ea.e_explain"/>
					</textarea>
					<span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td colspan="4">
					<input type="button" onclick="back()" value="返回" />&nbsp;&nbsp; 
					<input type="button" onclick="checkSubmit()" value="提交" />&nbsp;</td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
	var status = "<s:property value='ea.e_id' />";
	function checkSubmit(){
		var actionUrl;
		var valid = $("#form2").validationEngine({returnIsValid: true});
		if(!$('#visit').text()){
			$('#visit').css('border-color','red').attr('title','* 非空选项.');
			enableTooltips();
			valid = false;
		}
		if(!valid){
			return false;
		}
		if(status==0){
			actionUrl = webctx+"/reality/ea_insertErrandById.action";
		}else{
			actionUrl = webctx+"/reality/ea_updateErrandById.action";
		}
		var actionData = $("#form2").serialize();
		$.ajax({
			url:actionUrl,
			data:actionData,
			type : "post",
			cache : false,
			dataType : 'text',
			success : function(data) {
				if(data>0){
					alert('操作成功!');
				}else{
					alert('操作失败');
					return false;
				}
				window.location = webctx + "/reality/ea_queryErrand.action";
			}
		});
	}
	$(function(){
		$('textarea').blur(function(){
			if($(this).text()){
				$(this).css('border-color','');
				$('#visit').attr('title',$('#visit').val());
				enableTooltips();
			}
		});
	});
	function back() {
		top.Dialog.confirm("确认返回？", function() {
			showProgressBar();
			window.location = webctx + "/reality/ea_queryErrand.action";
		});

	}
</script>
</html>